diff options
Diffstat (limited to 'src/routes/tools/[tool]/+page.svelte')
| -rw-r--r-- | src/routes/tools/[tool]/+page.svelte | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/routes/tools/[tool]/+page.svelte b/src/routes/tools/[tool]/+page.svelte new file mode 100644 index 00000000..bd236d11 --- /dev/null +++ b/src/routes/tools/[tool]/+page.svelte @@ -0,0 +1,63 @@ +<script lang="ts"> + import ActivityHistory from '$lib/Tools/ActivityHistory/Tool.svelte'; + import Wrapped from '$lib/Tools/Wrapped.svelte'; + import EpisodeDiscussionCollector from '$lib/Tools/EpisodeDiscussionCollector.svelte'; + import CharacterBirthdays from '$lib/Tools/Birthdays.svelte'; + import SequelSpy from '$lib/Tools/SequelSpy.svelte'; + import { closest } from '$lib/Error/path'; + import HeadTitle from '$lib/HeadTitle.svelte'; + import RandomFollower from '$lib/Tools/RandomFollower.svelte'; + import DumpProfile from '$lib/Tools/DumpProfile.svelte'; + import { tools } from '$lib/Tools/tools.js'; + import { onMount } from 'svelte'; + import { goto } from '$app/navigation'; + import Picker from '$lib/Tools/Picker.svelte'; + + export let data; + + let tool = data.tool ?? 'default'; + + onMount(() => { + if (tool === 'default') goto('/tools'); + }); + + $: suggestion = closest(tool, Object.keys(tools)); +</script> + +<Picker bind:tool /> + +{#if !Object.keys(tools).includes(tool)} + <HeadTitle route="Tools" path="/tools" /> + + <div class="card"> + <p>Tool not found.</p> + + <blockquote style="margin: 0 0 0 1.5rem;"> + Did you mean "<a + href={`/tools/${tools[suggestion].id}`} + on:click={() => (tool = suggestion)} + style={suggestion === '...' ? 'pointer-events: none; color: inherit;' : ''} + > + {suggestion === '...' ? '...' : tools[suggestion].name}</a + >"? + </blockquote> + </div> +{:else} + <HeadTitle route={tools[tool].name} path={`/tools?tool=${tool}`} /> + + {#if tool === 'activity_history'} + <ActivityHistory user={data.user} /> + {:else if tool === 'wrapped'} + <Wrapped user={data.user} /> + {:else if tool === 'discussions'} + <EpisodeDiscussionCollector /> + {:else if tool === 'birthdays'} + <CharacterBirthdays /> + {:else if tool === 'sequel_spy'} + <SequelSpy user={data.user} /> + {:else if tool === 'random_follower'} + <RandomFollower /> + {:else if tool === 'dump_profile'} + <DumpProfile /> + {/if} +{/if} |